home *** CD-ROM | disk | FTP | other *** search
/ Stone Design / Stone Design.iso / Stone_Friends / Wave / WavesWorld / Source / Shaders / RCShaders / RCPits.sl < prev    next >
Encoding:
Text File  |  1995-03-22  |  514 b   |  22 lines

  1. /* Listing 16.30  Displacement shader using a texture for pits and gouges*/
  2. /* 
  3.  *  pits(): use a texture map to apply pits to a surface 
  4.  */
  5. displacement
  6. RCPits( 
  7.     float Km = 0.03; 
  8.     string marks = "" )
  9. {
  10.     float magnitude;
  11.  
  12.     /* Get the displacement, if any, from the texture map. */
  13.     if(marks != "")
  14.         magnitude = float texture(marks);    /* Use s, t */
  15.     else
  16.         magnitude = 0;
  17.  
  18. /* The texture determines the size of the gouge, scaled by Km. */
  19.     P += -Km * magnitude * normalize(N);
  20.     N = calculatenormal(P);
  21. }
  22.